//
//  RYAddDizhiCell.swift
//  SheYangBigData
//
//  Created by 宋海胜 on 2021/1/14.
//  Copyright © 2021 叁拾叁. All rights reserved.
//



import UIKit

class RYAddDizhiCell: SYBaseCell {
    
    var inputClosure: ((String) -> Void)?
    
    var bgView: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = .white
        v.layer.cornerRadius = 5
        v.layer.masksToBounds = true
        return v
    }()
    
    let title: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 14.autoFontSize()
        
        
        return v
    }()
    
    let content: UITextField = {
        let v:UITextField = UITextField()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 14.autoFontSize()
        
        v.textAlignment = .right
        return v
    }()
    
    override func initViews() {
        
 
        //当文本框内容改变时，将内容输出到控制台上
        content.rx.text.orEmpty.asObservable()
            .subscribe(onNext: {[weak self] in
                if let `self` = self {
                    self.inputClosure?($0)
                }
                print("您输入的是：\($0)")
            })
            .disposed(by: disposeBag)
        
        self.backgroundColor = Constant.bgViewColor
        contentView.addSubview(bgView)
        
        bgView.addSubview(title)
        bgView.addSubview(content)
        
        bgView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(15.autoWidth())
            make.bottom.equalToSuperview()
            make.left.equalToSuperview().offset(15.autoWidth())
            make.right.equalToSuperview().offset(-15.autoWidth())
        }
        
        title.snp.makeConstraints { (make) in
            make.top.bottom.equalToSuperview()
            make.left.equalToSuperview().offset(15)
            make.centerY.equalToSuperview()
            make.height.equalTo(44.autoWidth())
        }
        content.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-30)
            make.centerY.equalToSuperview()
            make.height.equalTo(15.autoWidth())
        }
    }

    

}



class RYAddDizhiChoiceCell: SYBaseCell {
    
    var bgView: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = .white
        v.layer.cornerRadius = 5
        v.layer.masksToBounds = true
        return v
    }()
    
    let arrow: UIImageView = {
        let v: UIImageView = UIImageView()
        v.image = UIImage(named: "arrow")
        return v
    }()
    
    let title: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 14.autoFontSize()
        v.text = "所在地区"
        
        return v
    }()
    
    let content: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0xA6A6A6)
        v.font = 14.autoFontSize()
        v.text = "请选择地区"
        
        return v
    }()
    
    override func initViews() {
        
 
        self.backgroundColor = Constant.bgViewColor
        contentView.addSubview(bgView)
        bgView.addSubview(arrow)
        bgView.addSubview(title)
        bgView.addSubview(content)
        
        bgView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(15.autoWidth())
            make.bottom.equalToSuperview()
            make.left.equalToSuperview().offset(15.autoWidth())
            make.right.equalToSuperview().offset(-15.autoWidth())
        }
        
        arrow.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-15)
            make.centerY.equalToSuperview()
            make.width.equalTo(7.autoWidth())
            make.height.equalTo(12.autoWidth())
        }
        title.snp.makeConstraints { (make) in
            make.top.bottom.equalToSuperview()
            make.left.equalToSuperview().offset(15)
            make.centerY.equalToSuperview()
            make.height.equalTo(44.autoWidth())
        }
        content.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-30)
            make.centerY.equalToSuperview()
            make.height.equalTo(15.autoWidth())
        }
    }

}


class RYAddDizhiDetailCell: SYBaseCell {
    
    var inputClosure: ((String) -> Void)?
    var bgView: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = .white
        v.layer.cornerRadius = 5
        v.layer.masksToBounds = true
        return v
    }()
    
    var textView: UITextView = {
        let v: UITextView = UITextView()
        v.font = 14.autoFontSize()
        v.textColor = UIColor(hex:0x333333)
        return v
    }()
    
    var moren: UILabel = {
        let v: UILabel = UILabel()
        v.font = UIFont.systemFont(ofSize: 14)
        v.textColor = UIColor(hex: 0xA6A6A6)
        v.text = "详细地址..."
        return v
    }()
    
    override func initViews() {
        
 
        //当文本框内容改变时，将内容输出到控制台上
        textView.rx.text.orEmpty.asObservable()
            .subscribe(onNext: {[weak self] in
                if let `self` = self {
                    self.inputClosure?($0)
                    if $0 == "" {
                        self.moren.isHidden = false
                    } else {
                        self.moren.isHidden = true
                    }
                }
                        print("您输入的是：\($0)")
                    })
            .disposed(by: disposeBag)
        
        self.backgroundColor = Constant.bgViewColor
            contentView.addSubview(bgView)
        bgView.addSubview(textView)
        textView.addSubview(moren)

        textView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(8.0)
            make.bottom.equalToSuperview().offset(-8.0)
            make.left.equalToSuperview().offset(15.0)
            make.right.equalToSuperview().offset(-15.0)
            make.height.equalTo(110.autoWidth())
            
        }
        moren.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(8.0)
            make.left.equalToSuperview().offset(5.0)
            make.right.equalToSuperview()
            make.height.equalTo(15.autoWidth())
        }
        
        
        bgView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(15.autoWidth())
            make.bottom.equalToSuperview()
            make.left.equalToSuperview().offset(15.autoWidth())
            make.right.equalToSuperview().offset(-15.autoWidth())
        }
        
    }

    

}
